package com.mind.adjust.service.impl;

import com.mind.customer.mapper.AjTicketTypeMapper;
import com.mind.system.domain.AjTicketType;
import com.mind.adjust.service.AjTicketTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


/**
 * 单据类型(AjTicketType)表服务实现类
 *
 * @author makejava
 * @since 2024-07-28 22:01:04
 */
@Service("ticketTypeService")
public class AjTicketTypeServiceImpl implements AjTicketTypeService {
    @Autowired
    private AjTicketTypeMapper ticketTypeMapper;

    /**
     * 查询单据类型信息集合
     * 
     * @param ticketType 单据类型信息
     * @return 单据类型信息集合
     */
    @Override
    public List<AjTicketType> selectTicketTypeList(AjTicketType ticketType)
    {
        return ticketTypeMapper.selectTicketTypeList(ticketType);
    }

    /**
     * 通过单据类型ID查询单据类型信息
     * 
     * @param ticketTypeId 单据类型ID
     * @return 角色对象信息
     */
    @Override
    public AjTicketType selectTicketTypeById(Long ticketTypeId)
    {
        return ticketTypeMapper.selectTicketTypeById(ticketTypeId);
    }

    /**
     * 删除单据类型信息
     * 
     * @param ticketTypeId 单据类型ID
     * @return 结果
     */
    @Override
    public int deleteTicketTypeById(Long ticketTypeId)
    {
        return ticketTypeMapper.deleteTicketTypeById(ticketTypeId);
    }

    /**
     * 批量删除单据类型信息
     * 
     * @param ticketTypeIds 需要删除的单据类型ID
     * @return 结果
     */
    @Override
    public int deleteTicketTypeByIds(Long[] ticketTypeIds)
    {
        return ticketTypeMapper.deleteTicketTypeByIds(ticketTypeIds);
    }

    /**
     * 新增保存单据类型信息
     * 
     * @param ticketType 单据类型信息
     * @return 结果
     */
    @Override
    public int insertTicketType(AjTicketType ticketType)
    {
        return ticketTypeMapper.insertTicketType(ticketType);
    }

    /**
     * 修改保存单据类型信息
     * 
     * @param ticketType 单据类型信息
     * @return 结果
     */
    @Override
    public int updateTicketType(AjTicketType ticketType)
    {
        return ticketTypeMapper.updateTicketType(ticketType);
    }
    
    /**
     * 批量插入
     *
     * @param ticketTypeList 附件类型信息
     * @return 结果
     */
    @Override
    public int batchInsert(List<AjTicketType> ticketTypeList) {
        int size = 0;
        for(AjTicketType ticketType: ticketTypeList) {
            if (ticketTypeMapper.selectTicketTypeByName(ticketType.getName()) == null){
                ticketTypeMapper.insertTicketType(ticketType);
                size ++;
            }
        }
        return size;
    }
}
